﻿using System;
using System.Collections.Generic;

using System.Text;
using System.Data;
using QUANLYCHAMCONG.BL.Entities;
using QUANLYCHAMCONG.DAO.Core;
using ModuleDALCore;

namespace QUANLYCHAMCONG.DAO.DAO
{
    public class STAFFDAO:DALBase
    {
        STAFF nv;
         private string _SpName;
        public string SpName
        {
            get { return "SpNHANVIEN"; }
            set { _SpName = value; }
        }
        public STAFFDAO()
        {
            OpenConnect();
        }
        public bool Insert(STAFF nv)
        {
            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(nv, null), ConvertClassToArray.GetValues(nv,1)) == 1);
            }
            catch
            {
                return false;
            }
        }
        public bool Insert(bool insert,STAFF nv)
        {
            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(nv, null), ConvertClassToArray.GetValues(nv, 11)) == 1);
            }
            catch
            {
                return false;
            }
        }
        public bool Insert(int? flag,STAFF nv)
        {
            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(nv, null), ConvertClassToArray.GetValues(nv, 10)) == 1);
            }
            catch
            {
                return false;
            }
        }
        public bool Update(STAFF nv)
        {
            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(nv, null), ConvertClassToArray.GetValues(nv,2)) == 1);
            }
            catch
            {
                return false;
            }
        }
        public bool Delete(STAFF nv)
        {
            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(nv, null), ConvertClassToArray.GetValues(nv,3)) == 1);
            }
            catch
            {
                return false;
            }
        }
        public DataTable SelectByPK(STAFF nv)
        {
            try
            {
                return DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(nv, null), ConvertClassToArray.GetValues(nv,4));
            }
            catch
            {
                return null;
            }
        }
        public DataTable SelectALL()
        {
            nv = new STAFF();
            try
            {
                return DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(nv, null), ConvertClassToArray.GetValues(nv,0));
            }
            catch
            {
                return null;
            }
        }
        public DataTable SelectFollowPB(STAFF nv)
        {
            try
            {
                return DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(nv, null), ConvertClassToArray.GetValues(nv, 12));
            }
            catch
            {
                return null;
            }
        }
        public int GetID()
        {
            nv = new STAFF();
            try
            {
                return DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(nv, null), ConvertClassToArray.GetValues(nv, 5), DBConnectionState.CloseOnExit);
            }
            catch
            {
                return 0;
            }
        }
        public bool ExistsNumBerMachine(STAFF nv)
        {
            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(nv, null), ConvertClassToArray.GetValues(nv, 6)) == 1);
            }
            catch
            {
                return false;
            }
        }
        public bool ExistsNameMachine(STAFF nv)
        {
            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(nv, null), ConvertClassToArray.GetValues(nv, 7)) == 1);
            }
            catch
            {
                return false;
            }
        }
        public DataTable SelectbyGroupPB_CV(STAFF nv)
        {
            try
            {
                return DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(nv, null), ConvertClassToArray.GetValues(nv, 8));
            }
            catch
            {
                return null;
            }
        }
        public DataTable CheckExitsStaff(STAFF nv)
        {
            try
            {
                return DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(nv, null), ConvertClassToArray.GetValues(nv, 9));
            }
            catch
            {
                return null;
            }
        }
        public DataTable PrintStaff()
        {
            STAFF nv = new STAFF();
            try
            {
                return DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(nv, null), ConvertClassToArray.GetValues(nv, 13));
            }
            catch
            {
                return null;
            }
        }
    }
}
